/*
 * PromocionPeon.java
 *
 * Created on 21 de julio de 2007, 11:10 PM
 */

package ajedrezLogica;
import javax.swing.*;

/**
 *
 * @author  Billy
 */
public class PromocionPeon extends javax.swing.JDialog {
    char piezaPromocion;
    
    /** Creates new form PromocionPeon */
    public PromocionPeon(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        ButtonGroup grupodeBotones = new ButtonGroup();
        grupodeBotones.add(rbAlfil);
        grupodeBotones.add(rbCaballo);
        grupodeBotones.add(rbDama);
        grupodeBotones.add(rbTorre);          
    }
    
    public void ElijaPiezaPromocion(){
        if(this.rbAlfil.isSelected()== true) piezaPromocion='A';        
        else if(this.rbCaballo.isSelected()== true) piezaPromocion='C';
        else if(this.rbDama.isSelected()== true) piezaPromocion='D';
        else if(this.rbTorre.isSelected()== true) piezaPromocion='T';        
        
    }
    
    public char damePieza(){
        return piezaPromocion;
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblPromocion = new javax.swing.JLabel();
        rbDama = new javax.swing.JRadioButton();
        rbTorre = new javax.swing.JRadioButton();
        rbAlfil = new javax.swing.JRadioButton();
        rbCaballo = new javax.swing.JRadioButton();
        btnPromocion = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Promocion de Peon");

        lblPromocion.setText("Elija la pieza que desea canjear por el peon:");

        rbDama.setSelected(true);
        rbDama.setText("Dama");
        rbDama.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        rbDama.setMargin(new java.awt.Insets(0, 0, 0, 0));
        rbDama.setName("rbDama"); // NOI18N
        rbDama.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbDamaActionPerformed(evt);
            }
        });

        rbTorre.setText("Torre");
        rbTorre.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        rbTorre.setMargin(new java.awt.Insets(0, 0, 0, 0));

        rbAlfil.setText("Alfil");
        rbAlfil.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        rbAlfil.setMargin(new java.awt.Insets(0, 0, 0, 0));
        rbAlfil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbAlfilActionPerformed(evt);
            }
        });

        rbCaballo.setText("Caballo");
        rbCaballo.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        rbCaballo.setMargin(new java.awt.Insets(0, 0, 0, 0));

        btnPromocion.setText("Aceptar");
        btnPromocion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPromocionActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(rbTorre)
                            .addComponent(rbDama)
                            .addComponent(rbAlfil)
                            .addComponent(lblPromocion)
                            .addComponent(rbCaballo)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(90, 90, 90)
                        .addComponent(btnPromocion)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblPromocion)
                .addGap(15, 15, 15)
                .addComponent(rbDama)
                .addGap(14, 14, 14)
                .addComponent(rbTorre)
                .addGap(16, 16, 16)
                .addComponent(rbAlfil)
                .addGap(15, 15, 15)
                .addComponent(rbCaballo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnPromocion)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnPromocionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPromocionActionPerformed
// TODO add your handling code here:
        ElijaPiezaPromocion();
        this.dispose();
        
    }//GEN-LAST:event_btnPromocionActionPerformed

    private void rbAlfilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbAlfilActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_rbAlfilActionPerformed

    private void rbDamaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbDamaActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_rbDamaActionPerformed
    
    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                new PromocionPeon(new javax.swing.JFrame(), true).setVisible(true);
//            }
//        });
//    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnPromocion;
    private javax.swing.JLabel lblPromocion;
    private javax.swing.JRadioButton rbAlfil;
    private javax.swing.JRadioButton rbCaballo;
    private javax.swing.JRadioButton rbDama;
    private javax.swing.JRadioButton rbTorre;
    // End of variables declaration//GEN-END:variables
    
}
